package com.ugood.utils;

import java.util.Random;

/**
 * @Description: 流水单号
 * @Author: org
 * @CreateDate: 2018/10/16 14:38
 */
public class SeriaNumberUtil {

    public static String getNumber(){
        int length = 10;
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }

    /**
     * 生成指定位数随机数
     * @param length
     * @return
     */
    public static String getNumber(int length){
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }
}
